package com.hbusa.cotroller.image; /**
 * @author XiaoXin
 * @date 2021/12/27 - 2:19
 */


import com.hbusa.dto.TbPicture;
import com.hbusa.service.impl.ImageServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "AddServlet", value = "/admin/doAdd")
public class AddServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String url = (String)req.getAttribute("url");
        System.out.println(url);
        ImageServiceImpl imageService = new ImageServiceImpl();
        TbPicture picture = new TbPicture();
        picture.setPictureUrl(url);
        boolean add = imageService.add(picture);
        if (add) {
            System.out.println("插入成功");
        } else {
            System.out.println("插入失败");
        }
        req.getRequestDispatcher("doList").forward(req, resp);
    }
}
